using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

using miciv;
using miciv.Rendering;

namespace micivCore.Data
{
    public class UnitTechniqueBase : IUnitTechnique
    {
        protected CoreContext m_coreContext;
        protected string m_strID;
        protected TextureManager.ManagedTexture m_iconTexture;
        protected StringInfo m_textInfo;

        public UnitTechniqueBase(CoreContext _coreContext, XmlElement _xmlTechnique)
        {
            XmlElement xmlUI = _xmlTechnique.SelectSingleNode("ui") as XmlElement;
            this.m_coreContext = _coreContext;
            this.m_strID = _xmlTechnique.Attributes["id"].Value;
            this.m_iconTexture = this.m_coreContext.GetData<TextureManager>("TextureManager").GetTexture(xmlUI.Attributes["icon"].Value);
            this.m_textInfo = this.m_coreContext.GetData<StringTableManager>("StringTableManager").GetString(xmlUI.Attributes["stringid"].Value);
        }

        #region IUnitTechnique Membres

        virtual public string ID
        {
            get
            {
                return this.m_strID;
            }
        }

        virtual public miciv.Rendering.TextureManager.ManagedTexture Icon
        {
            get
            {
                return this.m_iconTexture;
            }
        }

        virtual public miciv.StringInfo Text
        {
            get
            {
                return this.m_textInfo;
            }
        }

        virtual public bool Apply(IUnit _unit)
        {
            return true;
        }

        #endregion
    }
}
